##提取生存数据
row.names(x) <- x$patient.bcr_patient_barcode
x <- x[!(grepl(".drug.",names(x)))]
x <- x[!(grepl(".admin.",names(x)))]
x <- x[!(grepl(".day_of_form_completion",names(x)))]
x <- x[!(grepl(".month_of_form_completion",names(x)))]
x <- x[!(grepl(".year_of_form_completion",names(x)))]
death <- x[grepl(".days_to_death",names(x))]
death[c(1:ncol(death))] <- lapply(death[c(1:ncol(death))],as.numeric)
alive <- x[grepl(".days_to_last_followup",names(x))]
alive[c(1:ncol(alive))] <- lapply(alive[c(1:ncol(alive))],as.numeric)
alive2 <- alive[1]
status <- x[grepl(".vital_status",names(x))]
stage <- x[names(x) %in% c("patient.stage_event.pathologic_stage",                                 
                           "patient.stage_event.tnm_categories.pathologic_categories.pathologic_m",
                           "patient.stage_event.tnm_categories.pathologic_categories.pathologic_n",
                           "patient.stage_event.tnm_categories.pathologic_categories.pathologic_t")]
age <- x[grepl(".age.",names(x))] 
gender <- x[grepl(".gender",names(x))]
type <- x[grepl(".histological_type",names(x))]
renkou <- cbind(age[,1],gender,type[,1])
for (i in 1:nrow(status)) {
  a <- as.data.frame(table(status[i,c(1:5)] %in% c("dead")))
  a$Var1 <- as.character(a$Var1)
  if (length(a$Var1 > 1)){status$Status[i] = "dead"}
  if (length(a$Var1) == 1 & a$Var1 == "FALSE"){status$Status[i] = "alive"}
  if (length(a$Var1) == 1 & a$Var1 == "TRUE"){status$Status[i] = "dead"}
  remove(a)
}
for (i in 1:nrow(death)) {
  death$Death[i] = max(death[i,],na.rm = T)
}
for (i in 1:nrow(alive)) {
  a <- as.data.frame(t(alive[i,]))
  alive2$patient.days_to_last_followup[i] = max(a[,1],na.rm = T)
  remove(a)
}
OS <- cbind(status$Status,alive2,death$Death)
for (i in 1:nrow(OS)) {
  if (OS$`status$Status`[i] == "alive"){OS$`death$Death`[i] = 0}
  if (OS$`status$Status`[i] == "dead"){OS$patient.days_to_last_followup[i] = 0}
  OS$Time[i] <- OS$patient.days_to_last_followup[i]+OS$`death$Death`[i]
}
clinical <- cbind(renkou,OS[c(1,4)],stage)
xlsx::write.xlsx(clinical,file = "E:/Data/UCEC/Clinicall.xlsx")
remove(list = ls())
gc()














xMax =  max(abs(c$deltaBeta))
yMax = max(-log10(c$adj.P.Val))
plot(c$deltaBeta,-log10(c$adj.P.Val), xlab="deltaBeta",ylab="dj.P.Val",main="Volcano", xlim=c(-xMax,xMax),ylim=c(0,yMax),yaxs="i",pch=1, cex=1)
abline(h=-log10(0.01),lty=2,lwd=3)
abline(v=-0.2,lty=2,lwd=3)
abline(v= 0.2,lty=2,lwd=3)
diffSub=c[c$deltaBeta >= 0.2 & c$adj.P.Val < 0.01,]
points(diffSub$deltaBeta,-log10(diffSub$adj.P.Val), pch=1, col="red",cex=1)
diffSub=c[c$deltaBeta <= -0.2 & c$adj.P.Val < 0.01,]
points(diffSub$deltaBeta,-log10(diffSub$adj.P.Val), pch=1, col="green",cex=1)



